<template>
    <div v-if="list">
        <dl v-if="OtherSubmit.type==2 && submit.market == 'HKEX'"><!-- 港股利润表 -->
            <dd>
                {{$t('info.info_finance_left.56hz6ccgu5o0')}} 
                <!-- 港股营业收入合计 -->
                <span class="fr" v-if="list.total_operating_income">{{dealNum(list.total_operating_income)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgutg0')}} 
                <span class="fr" v-if="list.gross_profit">{{dealNum(list.gross_profit)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd v-if="submit.market == 'HKEX'">
                {{$t('info.info_finance_left.56hz6ccguy00')}}
                <span class="fr" v-if="list.basic_earnings_pershare">{{dealNum(list.basic_earnings_pershare)}}</span>
                <span v-else class="fr">--</span>
            </dd>
        </dl>
        <dl v-if="OtherSubmit.type==2 && submit.market == 'US'"><!-- 美股利润表 -->
            <dd>
                {{$t('info.info_finance_left.56hz6ccgu5o0')}} 
                <!-- 美股营业收入 -->
                <span class="fr" v-if="list.shop_income">{{dealNum(list.shop_income)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgutg0')}} 
                <span class="fr" v-if="list.gross_profit">{{dealNum(list.gross_profit)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgv1c0')}}
                <span class="fr" v-if="list.basic_earnings_pershare">{{dealNum(list.basic_earnings_pershare)}}</span>
                <span v-else class="fr">--</span>
            </dd>
        </dl>
        <dl v-if="OtherSubmit.type==2 && (submit.market == 'SSE' || submit.market == 'SZSE')"><!-- 利润表 -->
            <dd>
                {{$t('info.info_finance_left.56hz6ccgu5o0')}}
                <!-- 沪深营业收入 -->
                <span class="fr" v-if="list.business_income">{{dealNum(list.business_income)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgv4g0')}} 
                <span class="fr" v-if="list.net_profit">{{dealNum(list.net_profit)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgv1c0')}}
                <span class="fr" v-if="list.basic_pershare_profit">{{dealNum(list.basic_pershare_profit)}}</span>
                <span v-else class="fr">--</span>
            </dd>
        </dl>
        <dl v-if="OtherSubmit.type==0 && submit.market == 'HKEX'"><!-- 港股资产负债表 -->
            <dd>
                {{$t('info.info_finance_left.56hz6ccgv800')}}
                <span class="fr" v-if="list.total_assets">{{dealNum(list.total_assets)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgvb00')}}
                <span class="fr" v-if="list.total_liabilities">{{dealNum(list.total_liabilities)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgve00')}}
                <span class="fr" v-if="list.aggregate_interest">{{dealNum(list.aggregate_interest)}}</span>
                <span v-else class="fr">--</span>
            </dd>
        </dl>
        <dl v-if="OtherSubmit.type==0 && submit.market == 'US'"><!-- 美股资产负债表 -->
            <dd>
                {{$t('info.info_finance_left.56hz6ccgv800')}}
                <span class="fr" v-if="list.total_assets">{{dealNum(list.total_assets)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgvb00')}}
                <span class="fr" v-if="list.total_liabilities">{{dealNum(list.total_liabilities)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgvh00')}}
                <span class="fr" v-if="list.total_equity">{{dealNum(list.total_equity)}}</span>
                <span v-else class="fr">--</span>
            </dd>
        </dl>
        <dl v-if="OtherSubmit.type==0 && (submit.market == 'SSE' || submit.market == 'SZSE')"><!-- 沪深资产负债表 -->
            <dd>
                {{$t('info.info_finance_left.56hz6ccgvk40')}}
                <span class="fr" v-if="list.total_assets">{{dealNum(list.total_assets)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgvms0')}}
                <span class="fr" v-if="list.total_liabilities">{{dealNum(list.total_liabilities)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgvps0')}}
                <span class="fr" v-if="list.capital_pay">{{dealNum(list.capital_pay)}}</span>
                <span v-else class="fr">--</span>
            </dd>
        </dl>
        <dl v-if="OtherSubmit.type==1 && submit.market == 'HKEX'"><!-- 港股现金流量表 -->
            <dd>
                {{$t('info.info_finance_left.56hz6ccgvso0')}}
                <span class="fr" v-if="list.flow_investment_activities">{{dealNum(list.flow_investment_activities)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgvws0')}}
                <span class="fr" v-if="list.financing_activities">{{dealNum(list.financing_activities)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgvzg0')}}
                <span class="fr" v-if="list.net_cash">{{dealNum(list.net_cash)}}</span>
                <span v-else class="fr">--</span>
            </dd>
        </dl>
        <dl v-if="OtherSubmit.type==1 && submit.market == 'US'"><!-- 美股现金流量表 -->
            <dd>
                {{$t('info.info_finance_left.56hz6ccgvso0')}}
                <span class="fr" v-if="list.flow_investment_activities">{{dealNum(list.flow_investment_activities)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgw280')}}
                <span class="fr" v-if="list.financing_activities">{{dealNum(list.financing_activities)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgv4g0')}}
                <span class="fr" v-if="list.net_profit">{{dealNum(list.net_profit)}}</span>
                <span v-else class="fr">--</span>
            </dd>
        </dl>
        <dl v-if="OtherSubmit.type==1 && (submit.market == 'SSE' || submit.market == 'SZSE')"><!-- 沪深现金流量表 -->
            <dd>
                {{$t('info.info_finance_left.56hz6ccgvso0')}}
                <span class="fr" v-if="list.flow_investment_activities">{{dealNum(list.flow_investment_activities)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgw280')}}
                <span class="fr" v-if="list.cash_flows">{{dealNum(list.cash_flows)}}</span>
                <span v-else class="fr">--</span>
            </dd>
            <dd>
                {{$t('info.info_finance_left.56hz6ccgw5c0')}}
                <span class="fr" v-if="list.final_cash">{{dealNum(list.final_cash)}}</span>
                <span v-else class="fr">--</span>
            </dd>
        </dl>
    </div>
</template>
<script>
import {get_charts} from '@/assets/js/API/info.js';
    export default {
        props: ["OtherSubmit", "submit"],
        data() {
            return{
                list:{
                    business_income:0,
                    gross_profit:0,
                    net_profit:0,
                    basic_earnings_pershare:0,
                    total_assets:0,
                    total_liabilities:0,
                    total_current_assets:0,
                    total_current_liabilities:0,
                    aggregate_interest:0,
                },
                lang: "zh-CN",
            };
        },
        mounted() {
            this.lang=localStorage.getItem("lang");
            this.$nextTick(function(){
                this.getCharts()
            })
        },
        methods: {
            //获取详情数据
            getCharts(){
                var _this = this;
                get_charts({
                        symbol:_this.submit.symbol,
                        market:_this.submit.market,
                        securityType:_this.submit.securityType,
                        type:_this.OtherSubmit.type,
                        period:_this.OtherSubmit.period,
                    }).then(function(res) {
                    if (res.code == 1) {
                        _this.list  = res.data.list[0];
                        console.log(_this.list.report_date.split('-')[0])
                    }else{

                    }
                })
                .catch(function(error) {
                    console.log(error);
                });
            },
            dealNum: function (num,show) {
                if(show){
                    return num
                }
                if(num=='--' || num==''){
                    return '--'
                }
                let number = Number(num)
                if (number == 0) {
                    return 0
                } else if (this.lang == 'zh-CN') {
                    if (Math.abs(number) >= 100000000) {
                        return (number / 100000000).toFixed(2) + this.$t('info.info_finance_left.56hz6ccgw800')
                    }else if(Math.abs(number) < 100000000  && Math.abs(number) >= 10000) {
                        return (number / 10000).toFixed(2) + this.$t('info.info_finance_left.56hz6ccgwao0')
                    }else{
                        return (number).toFixed(2)
                    }
                } else if (this.lang == 'en') {
                    if (Math.abs(number) >= 1000000000) {
                        return (number / 1000000000).toFixed(2) + 'B'
                    } else if (Math.abs(number) >= 1000000 && Math.abs(number) < 1000000000) {
                        return (number / 1000000).toFixed(2) + 'M'
                    } else if(Math.abs(number) >= 1000 && Math.abs(number) < 1000000) {
                        return (number / 1000).toFixed(2) + 'K'
                    }else{
                        return number
                    }
                }
            },
        },
        watch: {
            submit:{
                handler(val){
                    console.log(val,'submit2')
                    this.submit = val
                    this.getCharts()
                },
                deep:true
            } 
        },
        computed: {
            StockData() {
                return this.$store.state.index.StockData;
            }
        }
    }
</script>